package com.example.controller.stock;

import com.example.pojo.stock.Product_import;
import com.example.service.commodity.ImportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.ArrayList;
import java.util.List;
@Controller
@RequestMapping("/import")
public class ImportController {
    @Autowired
    private ImportService importService;

    @RequestMapping("/queryAll")
    public String queryAll(Model model) {
        List<Product_import> product_importList = importService.queryAll();
        System.out.println(product_importList);
        model.addAttribute("importList", product_importList);
        return "/stock/importRecord";
    }

    @RequestMapping("/queryImportByDate")
    public String queryImportByDate(@RequestParam("date") String date, Model model) {
        List<Product_import> product_importList = new ArrayList<>();
        Product_import product_import = importService.queryByDate(date);
        System.out.println("-----------------");
        System.out.println(product_import);
        product_importList.add(product_import);
        model.addAttribute("importList", product_importList);
        return "/stock/importRecord";
    }


}
